package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingDeviceAichat;
import com.ruoyi.ring.service.IRingDeviceAichatService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * AI聊天Controller
 * 
 * @author liuwp
 * @date 2025-10-11
 */
@RestController
@RequestMapping("/ring/ring_device_aichat")
public class RingDeviceAichatController extends BaseController
{
    @Resource
    private IRingDeviceAichatService ringDeviceAichatService;

    /**
     * 查询AI聊天列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_device_aichat:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingDeviceAichat ringDeviceAichat)
    {
        startPage();
        List<RingDeviceAichat> list = ringDeviceAichatService.selectRingDeviceAichatList(ringDeviceAichat);
        return getDataTable(list);
    }

    /**
     * 导出AI聊天列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_device_aichat:export')")
    @Log(title = "AI聊天", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingDeviceAichat ringDeviceAichat)
    {
        List<RingDeviceAichat> list = ringDeviceAichatService.selectRingDeviceAichatList(ringDeviceAichat);
        ExcelUtil<RingDeviceAichat> util = new ExcelUtil<RingDeviceAichat>(RingDeviceAichat.class);
        util.exportExcel(response, list, "AI聊天数据");
    }

    /**
     * 获取AI聊天详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_device_aichat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringDeviceAichatService.selectRingDeviceAichatById(id));
    }

    /**
     * 新增AI聊天
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_device_aichat:add')")
    @Log(title = "AI聊天", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingDeviceAichat ringDeviceAichat)
    {
        return toAjax(ringDeviceAichatService.insertRingDeviceAichat(ringDeviceAichat));
    }

    /**
     * 修改AI聊天
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_device_aichat:edit')")
    @Log(title = "AI聊天", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingDeviceAichat ringDeviceAichat)
    {
        return toAjax(ringDeviceAichatService.updateRingDeviceAichat(ringDeviceAichat));
    }

    /**
     * 删除AI聊天
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_device_aichat:remove')")
    @Log(title = "AI聊天", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringDeviceAichatService.deleteRingDeviceAichatByIds(ids));
    }
}
